import java.util.Scanner;

/**
 * Created with IDEA
 * author:ju bai
 * Date:2021/7/14
 * Time:16:24
 **/
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String ip = sc.nextLine();
            String num = sc.nextLine();
            ipToNum(ip);
            numToIp(num);
        }
    }

    /**
     * ip转十进制
     *
     * @param ip ip
     */
    private static void ipToNum(String ip) {
        String[] arr = ip.split("\\.");
        int[] arr2 = new int[arr.length];
        for (int i = 0; i < arr.length; i++) {
            arr2[i] = Integer.parseInt(arr[i]);
        }

        long n = 0;
        //Math.pow(m,n)  表示m的n次方  2的3*8次方
        for (int i = 0; i < arr2.length; i++) {
            n += (long) (arr2[i] * Math.pow(2, (arr2.length - 1 - i) * 8));
        }
        System.out.println(n);
    }

    /**
     * 十进制整数转ip
     *
     * @param num 十进制整数
     */
    private static void numToIp(String num) {
        long number = Long.parseLong(num);
        StringBuffer s = new StringBuffer();
        //转为二进制
        while (number != 0) {
            s.append(number % 2);
            number = number / 2;
        }
        s.reverse();//逆置

        //从后往前八个分割，因为自动trim，前面的0都没了
        String n1 = s.substring(0, s.length() - 24);
        String n2 = s.substring(s.length() - 24, s.length() - 16);
        String n3 = s.substring(s.length() - 16, s.length() - 8);
        String n4 = s.substring(s.length() - 8, s.length());
        //转换为十进制
        int s1 = Integer.valueOf(n1, 2);
        int s2 = Integer.valueOf(n2, 2);
        int s3 = Integer.valueOf(n3, 2);
        int s4 = Integer.valueOf(n4, 2);
        //拼接输出
        System.out.println(s1 + "." + s2 + "." + s3 + "." + s4);
    }
}
